$(document).ready ->
  $(document).on "click tap", "a.social-share-link", (e) ->
    socialLink = $(this)

    windowTitle = socialLink.attr('title')

    provider = socialLink.attr('data-media')
    url = socialLink.attr('data-url')
    title = socialLink.attr('data-title')
    text = socialLink.attr('data-text')

    switch provider
      when "facebook"
        windowUrl = "https://www.facebook.com/sharer.php?u=" + encodeURI(url)
      when "twitter"
        windowUrl = "https://twitter.com/share?url=" + encodeURI(url) + "&text=" + encodeURI(text)
      when "linkedin"
        windowUrl = "https://www.linkedin.com/shareArticle?mini=true&url=" + encodeURI(url) + "&title=" + encodeURI(title) + "&summary=" + encodeURI(text) + "&source=" + encodeURI(url)
      when "google"
        windowUrl = "https://plus.google.com/share?url+" + encodeURI(url)
      else
        return false

    width = 450
    height = 450
    left = parseInt($(window).width() / 2 - (width / 2))
    top = parseInt($(window).height() / 2 - (width / 2))

    windowFeatures = "width=#{width},height=#{height},left=#{left},top=#{top}"
    sharingWindow = window.open(windowUrl, windowTitle, windowFeatures)
    return false
